//
//  FZXLipinduihuanCollectionViewCell.m
//  SimulationShow
//
//  Created by apple on 2018/7/9.
//  Copyright © 2018年 apple. All rights reserved.
//

#import "FZXLipinduihuanCollectionViewCell.h"

@implementation FZXLipinduihuanCollectionViewCell


- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        self = [[NSBundle mainBundle]loadNibNamed:@"FZXLipinduihuanCollectionViewCell" owner:self options:nil].lastObject;

    }
    return self;
}
- (void)awakeFromNib {
    [super awakeFromNib];
    
    
    self.titleLab.textColor = rgb(40,40,40);
    self.nameLab.textColor = rgb(101,101,101);
    self.brithdayLab.textColor = rgb(101,101,101);
    self.descLab.textColor = rgb(101,101,101);
    
    
    self.followButton.layer.cornerRadius = 12;
    self.followButton.layer.masksToBounds = YES;
//    [self.followButton addTarget:self action:@selector(clickButton:) forControlEvents:UIControlEventTouchUpInside];
    self.icon.layer.cornerRadius = 37.5;
    self.icon.layer.masksToBounds = YES;
    // Initialization code
    UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:self.icon.bounds byRoundingCorners:UIRectCornerTopLeft|UIRectCornerTopRight cornerRadii:CGSizeMake(4,4)];
    
    CAShapeLayer *maskLayer = [[CAShapeLayer alloc]init];
    
    //设置大小
    maskLayer.frame = self.icon.bounds;
    
    //设置图形样子
    maskLayer.path = maskPath.CGPath;
    
    self.icon.layer.mask = maskLayer;
    self.layer.cornerRadius = 4;
    self.layer.masksToBounds = YES;
    self.titleLab.textColor = rgb(40,40,40);
    self.scoreLab.textColor = rgb(101,101,101);
    
    UIImageView *vipImageV = [[UIImageView alloc]init];
    vipImageV.image = [UIImage imageNamed:@"wk_vip"];
    vipImageV.contentMode = UIViewContentModeScaleAspectFill;
    vipImageV.clipsToBounds = YES;
        _vipImageV = vipImageV;
    [self.bottomView addSubview:vipImageV];
    vipImageV.userInteractionEnabled = NO;
    vipImageV.layer.cornerRadius = 7.5;
    vipImageV.layer.masksToBounds = YES;
    [vipImageV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(self.icon).offset(0);
        make.size.mas_equalTo(CGSizeMake(15, 15));
        make.bottom.mas_equalTo(self.icon);
    }];
    
}
//- (void)clickButton:(UIButton *)sender{
//    if ([self.delegate respondsToSelector:@selector(clickFollowButton:)]) {
//        [self.delegate clickFollowButton:sender];
//    }
//}
- (void)setModel:(WKNiuwaModel *)model{
    _model = model;
    
    if ([model.isVip integerValue]==1) {
        _vipImageV.hidden = NO;
    }else{
        _vipImageV.hidden = YES;
    }
    self.titleLab.text = model.babyUsername;
    self.brithdayLab.text = model.studyNum;
    self.nameLab.text = [NSString stringWithFormat:@"%@ %@岁",model.babyNickname,model.ageYear];
    self.descLab.text = model.babyInfo;
//wk_girl  wk_boy
    if ([model.sex isEqualToString:@"1"]) {
        self.sexImageView.image = [UIImage imageNamed:@"wk_boy"];
    }else{
        self.sexImageView.image = [UIImage imageNamed:@"wk_girl"];
    }
    UIImage *image;
//vkboy@2x vkgirl
    if ([model.sex isEqualToString:@"1"]) {
       image = [UIImage imageNamed:@"vkboy"];
    }else{
        image = [UIImage imageNamed:@"vkgirl"];
    }
    NSString *urlstring = [NSString stringWithFormat:@"%@%@",Public_URL,model.headImg];
    [self.icon sd_setImageWithURL:[NSURL URLWithString:urlstring] placeholderImage:image];
    if ([model.isAtten isEqualToString:@"1"]) {
        [self.followButton setTitle:@"取消关注" forState:UIControlStateNormal];
        self.followButton.layer.cornerRadius = 12;
        self.followButton.layer.masksToBounds = YES;
        self.followButton.backgroundColor = [UIColor whiteColor];
        [self.followButton setTitleColor:rgb(233,84,18) forState:UIControlStateNormal];
        self.followButton.layer.borderColor = rgb(233,84,18).CGColor;
        self.followButton.layer.borderWidth = 1;
    }else{
        [self.followButton setTitle:@"关注" forState:UIControlStateNormal];
        self.followButton.layer.cornerRadius = 12;
        self.followButton.layer.masksToBounds = YES;
        self.followButton.backgroundColor = rgb(233,84,18);
        [self.followButton setTitleColor:rgb(255,255,255) forState:UIControlStateNormal];
    }
}

@end
